package com.xxl.job.executor.core.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class Consumer {
    public static void main(String[] args) throws Exception {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("117.158.15.170");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("test");
        connectionFactory.setPassword("123456");
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();
        String exchangeName = "sjlw.ai.exchange";
        String queueName = "sjlw_ai_statistical";
        String routingKey = "sjlw_ai_statistical";

        //String queueName = "sjlw_ai_event_data";
        //String routingKey = "sjlw_ai_event_data";

        //String queueName = "sjlw_ai_event_img";
        //String routingKey = "sjlw_ai_event_img";
        channel.exchangeDeclare(exchangeName, "direct", true, false, null);
        channel.queueDeclare(queueName, true, false, false, null);
        channel.queueBind(queueName, exchangeName, routingKey);

        channel.basicConsume(queueName, true, new MyConsumer(channel));
    }
}